package com.booktype.dao;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.booktype.bean.Booktype;

@Repository
public class BooktypeDao implements IBooktypeDao {
	@Resource
	private SessionFactory sessionFactory;
	
	private Session getSession() {
		return sessionFactory.getCurrentSession();
	}

	@Override
	public List<Booktype> getAllBooktype() {
		String query = "from Booktype";
		List<Booktype> orders = (List<Booktype>) getSession().createQuery(query).list();
		if (orders == null) {
			return null;
		}
		return orders;
	}

}
